package com.gw.vip.server.service.dao_service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gw.vip.server.dao.HisClearLedgerMapper;
import com.gw.vip.server.dto.HisClearLedgerListDto;
import com.gw.vip.server.po.HisClearLedger;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author GW
 * @description
 * @since 2022-05-10
 */
@Service
public class HisClearLedgerService extends ServiceImpl<HisClearLedgerMapper, HisClearLedger> {
    public IPage<HisClearLedger> getList(HisClearLedgerListDto dto) {
        QueryWrapper<HisClearLedger> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(StringUtils.isNotBlank(dto.getId()), HisClearLedger::getId, dto.getId());
        queryWrapper.lambda().eq(StringUtils.isNotBlank(dto.getCapitalId()), HisClearLedger::getCapitalId, dto.getCapitalId());
        queryWrapper.lambda().eq(dto.getClearDate()!=null, HisClearLedger::getClearDate, dto.getClearDate());
        queryWrapper.select().orderByDesc("crt_time");
        Page<HisClearLedger> page = new Page<>(dto.getCurrent(), dto.getSize());
        return page(page, queryWrapper);
    }
}
